<script setup lang="ts">
import { onMounted, reactive } from 'vue';
import { AdminInfoModel, ProjectExperienceModel, AbilityModel } from '@/api/webSite/response';
import { getAdminInfoApi, getProjectExperiencesApi, getAbilitiesApi } from '@/api/webSite/index';
import SkillCard from '@/components/Cards/SkillCard.vue';
import useElementPlusStore from '@/stores/UseElementPlusStore';

const adminInfo = reactive<AdminInfoModel>({} as AdminInfoModel);
const projectExperiences = reactive<Array<ProjectExperienceModel>>([]);
const abilities = reactive<Array<AbilityModel>>([]);

onMounted(async () => {
  Object.assign(adminInfo, await getAdminInfoApi());
  Object.assign(projectExperiences, await getProjectExperiencesApi());
  Object.assign(abilities, await getAbilitiesApi());

  useElementPlusStore().closeLoad();
})

</script>

<template>

  <div class="mainBody">
    <div class="card">
      <div class="info">
        <img src="/public/img/profile/card.png" class="cover" alt="">

        <div class="head">
          <div class="data">
            <div class="title1">Postive<span>VIP</span></div>
            <div class="title2">持续升级ing</div>
          </div>
        </div>

        <div class="foot">
          <div class="tags">
            <span class="tag" v-for="item in adminInfo.skills" :key="item">#{{ item }}</span>
          </div>
          <div class="introduce">
            <p v-html="adminInfo.desc">
            </p>
          </div>
        </div>

      </div>

      <div class="contact">
        <SkillCard :abilities="abilities" class="skill"></SkillCard>
      </div>

    </div>

    <div class="project">
      <div class="shell">
        <div class="header">
          <h2 class="title">项目时间线</h2>
          <h3 class="subTitle">Postive</h3>
        </div>
        <div class="timeline">

          <div v-for="item in projectExperiences" :key="item.id" class="item">
            <div class="content">
              <img :src="item.imageUrl" />
              <h2 class="content-title">{{ item.year }}</h2>
              <div class="content-body">
                <h2>{{ item.name }}</h2>
                <p>{{ item.desc }}</p>
              </div>
            </div>
          </div>

        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
@keyframes bgmove {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.mainBody {
  background-image: linear-gradient(125deg, #15191e, #27302b, #1d322c, #2d0f0c, #1c0128);
  background-size: 400%;
  animation: bgmove 20s infinite;
  display: flex;
  flex-direction: column;
  align-items: center;

  .card {
    margin-top: 90px;
    border-radius: 10px;
    box-shadow: 0px 0px 20px #eae9ec22;
    color: #fff;
    width: 90%;
    height: 680px;
    display: flex;
    flex-direction: row;

    .info {
      flex: 1;
      height: 650px;
      background: $bgColor;
      position: relative;
      margin-left: 10px;
      margin-top: 11px;

      .cover {
        position: absolute;
        top: 190px;
        left: 25px;
        width: 220px;
        z-index: 2;
        border-radius: 500px;
        border: 10px #fff solid;
        box-shadow: 0 5px 10px #00000065;
      }

      .head {
        height: 340px;
        position: relative;
        overflow: hidden;
        z-index: 1;

        .data {
          padding: 190px 0 0 280px;
          text-shadow: 0 0 20px #000;

          .title1 {
            color: white;
            font-size: 50px;
            margin-bottom: 5px;
            position: relative;

            span {
              position: absolute;
              top: 17px;
              margin-left: 12px;
              background: #ffe44c;
              border-radius: 5px;
              color: #000;
              font-size: 14px;
              padding: 14px;
              padding: 0px 4px;
            }
          }

          .title2 {
            color: #fff;
            font: 500 24px '';
          }
        }

        &::before {
          content: "";
          width: 100%;
          height: 100%;
          position: absolute;
          background-image: url('/public/img/profile/bg.png');
          background-size: cover;
          z-index: -1;
          transform: skewY(-4deg);
          transform-origin: 0 0;
        }
      }

      .foot {
        color: #444;
        display: flex;
        flex-direction: row;

        .tags {
          padding-left: 10px;
          padding-top: 10px;
          width: 250px;
          text-align: center;
          display: flex;
          flex-direction: row;
          flex-wrap: wrap;
          -ms-flex-align: center;

          .tag {
            background: rgb(149, 178, 255);
            color: #fff;
            width: 70px;
            height: 30px;
            border-radius: 10px;
            padding: 0px 8px;
            font-size: 10px;
            margin-right: 4px;
            line-height: 35px;
            cursor: pointer;

            &:hover {
              background: #eee4ad;
              color: #444;
            }

          }
        }

        .introduce {
          padding: 10px 0 0 35px;
          width: 480px;
          height: 300px;
          overflow: hidden;

          p {
            line-height: 2;
            text-indent: 2em;
            letter-spacing: 2px;
          }

        }
      }
    }

    .contact {
      flex: 1;
      height: 650px;
      position: relative;
      margin-left: 10px;
      margin-top: 11px;
      margin-right: 10px;
      background-image: url('/public/img/profile/contact_bg.jpg');
      background-position-x: center;
      background-position-y: center;
      background-size: 90%;
      background-repeat: no-repeat;

      .skill {
        width: 90%;
        margin: 0 auto;
        position: absolute;
        left: 5%;
        bottom: 0;
        height: 60%;
      }
    }
  }

  .project {
    margin-top: 40px;
    // border-radius: 10px;
    // box-shadow: 0px 0px 20px #eae9ec22;
    // background-color: black;
    width: 90%;

    .shell {
      width: 100%;
      position: relative;
      padding: 80px 0;
      transition: .3s ease 0s;

      .header {
        width: 100%;
        text-align: center;
        margin-bottom: 80px;
        position: relative;

        .title {
          color: #fff;
          font-size: 46px;
          font-weight: normal;
          margin: 0;
        }

        .subTitle {
          color: rgba(255, 255, 255, 0.5);
          font-size: 16px;
          letter-spacing: 5px;
          margin: 10px 0 0 0;
          font-weight: normal;
        }
      }

      .timeline {
        display: flex;
        margin: 0 auto;
        flex-wrap: wrap;
        flex-direction: column;
        max-width: 700px;
        position: relative;


        &::before {
          position: absolute;
          left: 50%;
          width: 2px;
          height: 100%;
          margin-left: -1px;
          content: "";
          background: rgba(255, 255, 255, 0.07);
        }

        .item {
          padding: 40px 0;
          transition: .5s;
          box-sizing: border-box;
          width: calc(70% - 40px);
          display: flex;
          position: relative;
          transform: translateY(-80px);

          &:nth-child(even) {
            align-self: flex-end;
          }

          .content {

            img {
              max-width: 100%;
              box-shadow: 0 40px 40px rgba(0, 0, 0, 0.4);
            }

            .content-title {
              font-weight: normal;
              font-size: 66px;
              margin: -10px 0 0 0;
              transition: 0.4s;
              padding: 0 10px;
              box-sizing: border-box;
              color: #fff;
            }

            .content-body {
              margin: 0;
              font-size: 15px;
              box-sizing: border-box;
              color: rgba(255, 255, 255, 0.7);
              line-height: 25px;

              h2 {
                font-size: 26px;
                line-height: 30px;
              }

              p {
                text-indent: 2em;
                margin-top: 10px;
                line-height: 27px;
                letter-spacing: 1px;
              }
            }

          }

        }
      }
    }

  }
}
</style>
